package com.fingard.dsp.bank.reqrespobj.contract.detail;

import com.fingard.constant.Format;
import com.fingard.dsp.bank.reqrespobj.authforrec.detail.ReqAuthForRecDetail;
import com.fingard.dsp.bank.reqrespobj.single.detail.ReqPayRecDetail;
import com.fingard.xml.XElement;
import com.fingard.xml.XmlTextReader;

import java.text.ParseException;
import java.util.Date;

public class ReqContractDetail extends ReqPayRecDetail {
	/** 步骤(01-签约申请, 02-签约确认) */
	public String step;
	
	/** 法人姓名 */
	public String legalName;
	
	/** 法人证件类型 */
	public String legalCertType;
	
	/** 法人证件号码 */
	public String legalCertNum;
	
	/** 合约到期日(格式:yyyyMMdd) */
	public String deadLine;
	
	/** 签约后单笔代扣最大限额 */
	public String singleLimit;
	
	/** 签约后单笔代扣日累计最大限额 */
	public String dayAmtLimit;
	
	/** 签约后单笔代扣月累计最大限额 */
	public String monthAmtLimit;
	
	/** 单笔代扣周期限制单位(1-日,2-月,3-年) */
	public String periodLimit;
	
	/** 签约单笔代扣最大代扣次数(范围:1-9999) */
	public String countLimit;
	
	/** 短信签约码 */
	public String token;
	/** 短信签约码 */
	public String jumpUrl;
	
	 /** 业务单据号（保单号） */
//    public String sourceNoteCode;
    
    /** 投保单号 */
//    public String insuPolicyNum;
    public String  busType;

	public ReqContractDetail(){
		
	}
	
	public void from(String pOwnAct, ReqAuthForRecDetail pAuthDetail) throws Exception {
		XElement tmpXElement = new XElement("DetailRecord", "");
		tmpXElement.addChild(new XElement("RecAct", pOwnAct));
		tmpXElement.addChild(new XElement("ReqSeqID", pAuthDetail.authCode));
		tmpXElement.addChild(new XElement("AuthCode", pAuthDetail.authCode));
		tmpXElement.addChild(new XElement("CellPhone", pAuthDetail.cellPhone));
		tmpXElement.addChild(new XElement("CardType", pAuthDetail.cardType));
		tmpXElement.addChild(new XElement("CertType", pAuthDetail.certType));
		tmpXElement.addChild(new XElement("CertNum", pAuthDetail.certNum));
		tmpXElement.addChild(new XElement("CNAPSCode", pAuthDetail.cnapsCode));
		tmpXElement.addChild(new XElement("PayBankCode", pAuthDetail.oppBank));
		tmpXElement.addChild(new XElement("PayArea", pAuthDetail.oppArea));
		tmpXElement.addChild(new XElement("PayStandardArea", pAuthDetail.oppArea));
		tmpXElement.addChild(new XElement("PayAct", pAuthDetail.oppAct));
		tmpXElement.addChild(new XElement("PayName", pAuthDetail.oppActName));
		tmpXElement.addChild(new XElement("IsPrivate", pAuthDetail.isPrivate));
		tmpXElement.addChild(new XElement("SourceNoteCode", pAuthDetail.sourceNoteCode));
		tmpXElement.addChild(new XElement("InsuPolicyNum", pAuthDetail.insuPolicyNum));

		srcXElement = tmpXElement;
		this.recAct = pOwnAct;
		this.askNumber = pAuthDetail.authCode;
		this.authCode = pAuthDetail.authCode;
		this.cellPhone = pAuthDetail.cellPhone;
		this.cardType = pAuthDetail.cardType;
		this.certType = pAuthDetail.certType;
		this.certNum = pAuthDetail.certNum;
		this.cnapsCode = pAuthDetail.cnapsCode;
		this.payBankCode = pAuthDetail.oppBank;
		this.payArea = pAuthDetail.oppArea;
		this.payStandardArea = pAuthDetail.oppArea;
		this.payAct = pAuthDetail.oppAct;
		this.payName = pAuthDetail.oppActName;
		this.isPrivate = pAuthDetail.isPrivate;
		this.sourceNoteCode = pAuthDetail.sourceNoteCode;
		this.insuPolicyNum = pAuthDetail.insuPolicyNum;
	}
	
	public ReqContractDetail(XElement p_xelement, String p_transType,String p_bankCode) throws Exception{
		super(p_xelement, p_transType,p_bankCode);
		step = p_xelement.getSingleTextNotNull("Step");
		legalName = p_xelement.getSingleTextNotNull("LegalName");
		legalCertType = p_xelement.getSingleTextNotNull("LegalCertType");
		legalCertNum = p_xelement.getSingleTextNotNull("LegalCertNum");
		deadLine = p_xelement.getSingleTextNotNull("DeadLine");
		singleLimit = p_xelement.getSingleTextNotNull("SingleLimit");
		periodLimit = p_xelement.getSingleTextNotNull("PeriodLimit");
		countLimit = p_xelement.getSingleTextNotNull("CountLimit");
		token = p_xelement.getSingleTextNotNull("Token");
		jumpUrl = p_xelement.getSingleTextNotNull("JumpUrl");
        busType = p_xelement.getSingleTextNotNull("BusType");
		dayAmtLimit = p_xelement.getSingleTextNotNull("DayAmtLimit");
		monthAmtLimit = p_xelement.getSingleTextNotNull("MonthAmtLimit");
	}
}